﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BathhouseService.Models.SqlModels;
using BathhouseService.CURD.ViewModels.PackageServiceSettingsVMs;

namespace BathhouseService.CURD.ViewModels.PackageServiceVMs
{
    public partial class PackageServiceListVM : BasePagedListVM<PackageService_View, PackageServiceSearcher>
    {
        public PackageServiceSettingsListVM2 PackageServiceSettings { get; set; } = new PackageServiceSettingsListVM2();


        protected override void InitVM()
        {

            PackageServiceSettings.CopyContext(this);
        }

        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.Create, "新建","CURD", dialogWidth: 800),
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.Edit, "修改","CURD", dialogWidth: 800),
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.Delete, "删除", "CURD",dialogWidth: 800),
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.Details, "详细","CURD", dialogWidth: 800),
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.BatchEdit, "批量修改","CURD", dialogWidth: 800),
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.BatchDelete, "批量删除","CURD", dialogWidth: 800),
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.Import, "导入","CURD", dialogWidth: 800),
                this.MakeStandardAction("PackageService", GridActionStandardTypesEnum.ExportExcel, "导出","CURD"),
                //this.MakeAction("PackageServiceOneSet","Index","设置套餐服务","Details new window", GridActionParameterTypesEnum.SingleId,"CURD").SetIsRedirect(true).SetShowInRow(true).SetShowDialog(false).SetHideOnToolBar(true),
                this.MakeAction("Home","Index","设置套餐服务","CURD", GridActionParameterTypesEnum.SingleId,null,500).SetOnClickScript("report2").SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-warm"),
            };
        }

        protected override IEnumerable<IGridColumn<PackageService_View>> InitGridHeader()
        {
            return new List<GridColumn<PackageService_View>>{
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.Describe),
                this.MakeGridHeader(x => x.Remark),
                this.MakeGridHeaderAction(width: 300)
            };
        }

        public override IOrderedQueryable<PackageService_View> GetSearchQuery()
        {
            var query = DC.Set<PackageService>()
                .CheckContain(Searcher.Name, x=>x.Name)
                .Select(x => new PackageService_View
                {
				    ID = x.ID,
                    Name = x.Name,
                    Describe = x.Describe,
                    Remark = x.Remark,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class PackageService_View : PackageService{

    }
}
